package com.lepu.pcecg500;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lepu.pcecg500.util.EcgTable;

import java.util.List;

public class BloodLipidHistoryAdapter extends BaseQuickAdapter<EcgTable, BaseViewHolder> {

    public BloodLipidHistoryAdapter(int layoutResId, @Nullable List<EcgTable> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, EcgTable item) {

        helper.setText(R.id.tv_code,item.getCode())
                .setText(R.id.tv_item_hr,item.getHr())
                .setText(R.id.tv_item_jielun,item.getConclusion());

        helper.addOnClickListener(R.id.tv_item_chakan);

        if (item.isSelect()) {
            helper.setBackgroundColor(R.id.rl_item,mContext.getResources().getColor(R.color.blue_00a9d6));
            helper.setTextColor(R.id.tv_code,mContext.getResources().getColor(R.color.white))
                    .setTextColor(R.id.tv_item_hr,mContext.getResources().getColor(R.color.white))
                    .setTextColor(R.id.tv_item_chakan,mContext.getResources().getColor(R.color.white))
                    .setTextColor(R.id.tv_item_jielun,mContext.getResources().getColor(R.color.white));
        }else {
            helper.setBackgroundColor(R.id.rl_item,mContext.getResources().getColor(R.color.white));
            if(item.getState().equals("0")){
                helper.setTextColor(R.id.tv_code,mContext.getResources().getColor(R.color.btn_green))
                        .setTextColor(R.id.tv_item_hr,mContext.getResources().getColor(R.color.btn_green))
                        .setTextColor(R.id.tv_item_chakan,mContext.getResources().getColor(R.color.btn_green))
                        .setTextColor(R.id.tv_item_jielun,mContext.getResources().getColor(R.color.btn_green));
            }else{
                helper.setTextColor(R.id.tv_code,mContext.getResources().getColor(R.color.red_text))
                        .setTextColor(R.id.tv_item_hr,mContext.getResources().getColor(R.color.red_text))
                        .setTextColor(R.id.tv_item_chakan,mContext.getResources().getColor(R.color.red_text))
                        .setTextColor(R.id.tv_item_jielun,mContext.getResources().getColor(R.color.red_text));
            }
        }

    }
}
